package com.sl.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sl.mapper.PaperQuestionsMapper;
import com.sl.mapper.QuestionOptionMapper;
import com.sl.mapper.QuestionsMapper;
import com.sl.pojo.Question;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class QuestionService {
    @Resource
    private QuestionsMapper questionsMapper;
    @Resource
    private QuestionOptionMapper questionOptionMapper;
    @Resource
    private PaperQuestionsMapper paperQuestionsMapper;

    //所有的问题。
    public Page<Question> findAllQuestions(Integer page, Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<Question> questions = questionsMapper.selectAll();
        return (Page<Question>)questions;
    }

    public void addQuestion(Question question){
         questionsMapper.insertSelective(question);
    }

    public Question findById(Integer id){
        Question question = questionsMapper.selectByPrimaryKey(id);
        return question;
    }
    public void deleted(Question question){
        questionsMapper.deleteByPrimaryKey(question);
    }
}
